<template>
  <div class="pugtablebox">
    <div class="mb-3 flex justify-between">
      <div>
        <el-button size="small" type="success" :icon="CirclePlus">新增</el-button>
        <el-button size="small" type="danger" :icon="Delete">批量删除</el-button>
        <el-button size="small" type="default" :icon="Top">上架</el-button>
        <el-button size="small" type="default" :icon="Bottom">下架</el-button>
      </div>
      <div>
        <el-input v-model="keyword" class="w-50 m-2" size="small" placeholder="请输入搜索关键词" :suffix-icon="Search" />
        <el-button size="small" type="success" :icon="Search">搜索</el-button>
      </div>
    </div>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column label="Date">
        <template #default="scope">
          <div style="display: flex; align-items: center">
            <el-icon>
              <timer />
            </el-icon>
            <span style="margin-left: 10px">{{ scope.row.date }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="Name">
        <template #default="scope">
          <el-popover effect="light" trigger="hover" placement="top" width="auto">
            <template #default>
              <div>name: {{ scope.row.name }}</div>
              <div>address: {{ scope.row.address }}</div>
            </template>
            <template #reference>
              <el-tag>{{ scope.row.name }}</el-tag>
            </template>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column label="Operations">
        <template #default="scope">
          {{ scope.row.status }}
          <el-switch v-model="scope.row.status" class="ml-2" width="60px" inline-prompt :active-value="1"
            :inactive-value="0" active-text="发布" inactive-text="不发布" />
        </template>
      </el-table-column>
      <el-table-column label="Operations">
        <template #default="scope">
          <el-button size="small" :icon="Edit" @click="handleEdit(scope.$index, scope.row)">Edit</el-button>
          <el-button size="small" type="danger" :icon="Delete" @click="handleDelete(scope.$index, scope.row)">Delete
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination class="justify-center mt-5" background layout="prev, pager, next" :total="1000" />
  </div>
</template>

<script setup>
import { Timer } from '@element-plus/icons-vue'
import { ref, reactive } from 'vue'
import { CirclePlus, Top, Bottom, Delete, Edit, Search, Share, Upload } from '@element-plus/icons-vue'

const keyword = ref("");


const handleEdit = (index, row) => {
  console.log(index, row)
}
const handleDelete = (index, row) => {
  console.log(index, row)
}

const tableData = [
  {
    date: '2016-05-03',
    name: 'Tom',
    status: 1,
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-02',
    name: 'Tom',
    status: 0,
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    status: 1,
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-01',
    name: 'Tom',
    status: 0,
    address: 'No. 189, Grove St, Los Angeles',
  },
];

</script>
